<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>${sysName}</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${resRoot}/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all" />
	<link rel="stylesheet" href="${resRoot}/layui/admin/admin.css" media="all" />
	<link id="layuicss-layer" rel="stylesheet" href="${resRoot}/layui/css/modules/layer/default/layer.css" media="all">
</head>
<body class="childrenBody">
	<div class="layui-fluid">   
          <div class="layui-card">
	<div class="layui-form layui-card-header layuiadmin-card-header-auto">
	<div class="layui-form-item">
		<@shiro.hasPermission name="article:show">
	  
	  <div class="layui-inline">
    <label class="layui-form-label">所属类型</label>
    <div class="layui-input-block">
      <select name="type" id="type" lay-verify="required" >
        <option value=""></option>
        <#list communityTypeList as communityType>
        <option value="${communityType.id}" <#if articleDTO.type?? && communityType.id ==articleDTO.type >selected="selected"</#if> >${communityType.name}</option>
        </#list>
      </select>
    </div>
  </div>
  
  <div class="layui-inline">
    <label class="layui-form-label">审核状态</label>
    <div class="layui-input-block">
      <select name="audit" id="audit" lay-verify="required" >
        <option value=""></option>
        <#list dictMap['audit_type']?keys as key>
        <option value="${key}" <#if articleDTO.audit?? && key==articleDTO.audit >selected="selected"</#if> >${dictMap['audit_type'][key]}</option>
        </#list>
      </select>
    </div>
  </div>
	  
		<div class="layui-inline">
		    <a class="layui-btn search_btn">查询</a>
		</div>
		</@shiro.hasPermission>
		<@shiro.hasPermission name="article:add">
		<div class="layui-inline">
			<a class="layui-btn linksAdd_btn" style="background-color:#5FB878" href="${base}/sys/article/input">添加社区类型</a>
		</div>
		</@shiro.hasPermission>
	</div>
	</div>
	
	
	<div class="layui-card-body">
	
	
	<div class="layui-form news_list">
	  	<table class="layui-table">
		    <colgroup>
				<col>
				<col>
				<col>
				<col>
				<col>
		    </colgroup>
		    <thead>
				<tr>
					<th style="text-align:left;">序号</th>
					<th>类型名称</th>
					<th>内容</th>
					<th>审核状态</th>
					<th>阅读量</th>
					<th>是否置顶</th>
					<th>创建时间</th>
					<th>操作</th>
				</tr>
		    </thead>
		    <tbody>
		    <@shiro.hasPermission name="article:show">
		    	<#list result.datas as articleDTO>
		    	<tr>
					<td style="text-align:left;">${(result.pageNumber - 1)*result.pageSize + articleDTO_index +1}</td>
					<td>${articleDTO.typeName!}</td>
					<td title="${articleDTO.content!}"><#if articleDTO.content?length &gt; 15 >${articleDTO.content?substring(0,15)}<#else>${articleDTO.content}</#if></td>
					<td><#if articleDTO.audit?? && articleDTO.audit=="0">待审核<#elseif articleDTO.audit?? && articleDTO.audit=="1">审核通过<#elseif articleDTO.audit?? && articleDTO.audit=="2">已驳回</#if></td>
					<td>${articleDTO.readCount}</td>
					<td>${dictMap['is_top'][articleDTO.isTop]}</td>
					<td>${articleDTO.createTime?datetime}</td>
					<td>
					<@shiro.hasPermission name="article:show">
					<a class="layui-btn layui-btn-normal layui-btn-xs" href="${base}/sys/article/detial?id=${articleDTO.id}"><i class="iconfont icon-edit"></i>详情</a>
					</@shiro.hasPermission>
					<@shiro.hasPermission name="article:edit">
						<#if articleDTO.isTop=="0">
						<a class="layui-btn layui-btn-normal layui-btn-xs" href="javascript:void(0);" onclick="isTop(${articleDTO.id});" ><i class="iconfont"></i>置顶</a>
						<#else>
						<a class="layui-btn layui-btn-normal layui-btn-xs" href="javascript:void(0);" onclick="cacleIsTop(${articleDTO.id});" ><i class="iconfont"></i>取消置顶</a>
						</#if>
					</@shiro.hasPermission>
					<@shiro.hasPermission name="article:audit">
						<#if articleDTO.audit?? && articleDTO.audit=="0">
							<a class="layui-btn layui-btn-normal layui-btn-xs" href="javascript:void(0);" onclick="audit(${articleDTO.id});" ><i class="iconfont"></i>审核</a>
						</#if>
					</@shiro.hasPermission>
					<@shiro.hasPermission name="articleComment:show">
					<a class="layui-btn layui-btn-normal layui-btn-xs" href="${base}/sys/articleComment/show?articleId=${articleDTO.id}"><i class="iconfont"></i>评论<#if articleDTO.commontAuditCount ?? && articleDTO.commontAuditCount &gt; 0>(${articleDTO.commontAuditCount})</#if></a>
					</@shiro.hasPermission>
					<@shiro.hasPermission name="articleLike:show">
					<a class="layui-btn layui-btn-normal layui-btn-xs" href="${base}/sys/articleLike/show?articleId=${articleDTO.id}"><i class="iconfont"></i>点赞</a>
					</@shiro.hasPermission>
					<@shiro.hasPermission name="article:del"> 
		        		<a class="layui-btn layui-btn-danger layui-btn-xs" href="javascript:void(0);" onclick="del(${articleDTO.id});" ><i class="layui-icon"></i>删除</a>
		        		</@shiro.hasPermission>
		        	</td>
				</tr>
				</#list>
				</@shiro.hasPermission>
			</tbody>
		</table>
	</div>
	<div id="page"></div>
	</div>
	</div>
	<script type="text/javascript" src="${resRoot}/layui/layui.js"></script>
	<script src="${resRoot}/js/jquery.min.js?v=2.1.4"></script>
	<script src="${resRoot}/layui/layui.all.js" charset="utf-8"></script>
	<#assign pageUrl=base + '/sys/article/show?'>
	
	<#if articleDTO?? && articleDTO.type??>
	<#assign pageUrl=pageUrl + 'type='+ articleDTO.type +'&' >
	</#if>
	
	<#if articleDTO?? && articleDTO.audit??>
	<#assign pageUrl=pageUrl + 'audit='+ articleDTO.audit +'&' >
	</#if>
	
	<#include "/page/page1.html">
	<script>
	$(".search_btn").click(function(){
	var type  = $("#type").val();
	var audit = $("#audit").val();
		  window.location.href='${base}/sys/article/show?type=' +  type + "&audit=" + audit;
	  });
	  		function del(id) {
  			var flag = 0;
  			layer.confirm('确定删除该条数据吗?', function(index){
  				$.ajax({
  					type : "post",
  					url : "${base}/sys/article/del",
  					data : {
  						id : id
  					},
  					dataType : "json",
  					async : false,
  					success : function(data) {
  						flag  = data.message;
  						if(flag == 1) {
  							layer.msg('删除成功！', {
  							  icon: 1,
  							  time: 2000 //2秒关闭（如果不配置，默认是3秒）
  							}, function(){
  								window.location.reload();
  							});   
  						} else {
  							layer.alert("服务器繁忙，请稍候再试！");
  						}
  					}
  				});
  			});
  		}
	  		
	  		function isTop(id) {
	  			var flag = 0;
	  			layer.confirm('确定置顶该条数据吗?', function(index){
	  				$.ajax({
	  					type : "post",
	  					url : "${base}/sys/article/isTop",
	  					data : {
	  						id : id
	  					},
	  					dataType : "json",
	  					async : false,
	  					success : function(data) {
	  						flag  = data.message;
	  						if(flag == 1) {
	  							layer.msg('置顶成功！', {
	  							  icon: 1,
	  							  time: 2000 //2秒关闭（如果不配置，默认是3秒）
	  							}, function(){
	  								window.location.reload();
	  							});   
	  						} else {
	  							layer.alert("服务器繁忙，请稍候再试！");
	  						}
	  					}
	  				});
	  			});
	  		}
	  		
	  		function cacleIsTop(id) {
	  			var flag = 0;
	  			layer.confirm('确定取消置顶该条数据吗?', function(index){
	  				$.ajax({
	  					type : "post",
	  					url : "${base}/sys/article/cacleIsTop",
	  					data : {
	  						id : id
	  					},
	  					dataType : "json",
	  					async : false,
	  					success : function(data) {
	  						flag  = data.message;
	  						if(flag == 1) {
	  							layer.msg('取消置顶成功！', {
	  							  icon: 1,
	  							  time: 2000 //2秒关闭（如果不配置，默认是3秒）
	  							}, function(){
	  								window.location.reload();
	  							});   
	  						} else {
	  							layer.alert("服务器繁忙，请稍候再试！");
	  						}
	  					}
	  				});
	  			});
	  		}
	  		
	  		
	  		function audit(id) {
	  			layer.confirm('确定审核该条数据吗？', {
	  			  btn: ['通过','驳回'] //按钮
	  			}, function(){
	  				$.ajax({
						type : "post",
						url : "${base}/sys/article/audit",
						data : {
							id : id
							},
						dataType : "json",
						async : false,
						success : function(data) {
							 if(data.message == 1) {
									layer.msg('审核成功！', {
									  icon: 1,
									  time: 2000 //2秒关闭（如果不配置，默认是3秒）
									}, function(){
										window.location.reload();
									});   
								} else {
									layer.msg('系统繁忙！'); 
								}
						}
					}); 
	  			}, function(){
	  				$.ajax({
						type : "post",
						url : "${base}/sys/article/reject",
						data : {
							id : id
							},
						dataType : "json",
						async : false,
						success : function(data) {
							 if(data.message == 1) {
									layer.msg('驳回成功！', {
									  icon: 1,
									  time: 2000 //2秒关闭（如果不配置，默认是3秒）
									}, function(){
										window.location.reload();
									});   
								} else {
									layer.msg('系统繁忙！'); 
								}
						}
					}); 
	  			});
	  			
	  			
	  		}
	  		
	  		

layui.use("form", function () {
		var form = layui.form;
form.on('select(getCommunityTypeList)', function(data){
        
        var villageId=data.value;
		/* $.ajax({
						type : "post",
						url : "${base}/sys/article/getCommunityTypeList",
						data : {
							villageId : villageId
							},
						dataType : "json",
						async : false,
						success : function(data) {
							if(data.message != "") {
								var obj = data.message;
								var html = "<option value=''></option>";
								for(var i=0;i<obj.length;i++){
									html = html + "<option value='" + obj[i].id + "'>" + obj[i].name + "</option>";
								}
									$("#type").html(html);
								} else {
								var html = "<option value=''></option>";
								$("#type").html(html);
								}
									layui.use(['form'], function(){
  										var form = layui.form;
  										form.render();
  										});
						}
					});  */
     });
     });
</script>
</body>
</html>

